from django.shortcuts import render
from web.forms.project import ProjectModelForm
from django.http import JsonResponse


def project_list(request):
    """ 项目列表显示 """
    if request.method == 'GET':
        form = ProjectModelForm()
        context = {
            'form': form
        }
        return render(request, 'project_list.html', context)
    form = ProjectModelForm(data=request.POST)
    if form.is_valid():
        # 添加项目
        return JsonResponse({'status': True})
    return JsonResponse({'status': False, 'error': form.errors})